package com.rc.saas.tenant.service.channel;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.mapper.channel.RcChannelGainSettingMapper;
import com.rc.saas.tenant.model.channel.RcChannelGainSetting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RcChannelGainSettingServiceImpl implements RcChannelGainSettingService{

    @Autowired
    private RcChannelGainSettingMapper channelGainSettingMapper;

    @Override
    public RcChannelGainSettingMapper getMapper() {
        return channelGainSettingMapper;
    }

    @Override
    public PageInfo listPageChannelGain(String channelLevel, String gainName, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<RcChannelGainSetting> list = channelGainSettingMapper.listChannelGain(channelLevel, gainName);
        return new PageInfo(list);
    }

    @Override
    public void saveChannelGain(RcChannelGainSetting gainSetting) {
        if (gainSetting.getChannelGainId() == null) {
            channelGainSettingMapper.insertSelective(gainSetting);
        } else {
            channelGainSettingMapper.updateByPrimaryKeySelective(gainSetting);
        }
    }
}
